export default function useEchartMapOption(mapName) {
  const TempSources = {
    compId: mapName,
  };
  var center = {
    南京市: [118.767413, 32.041544],
    无锡市: [120.301663, 31.574729],
    徐州市: [117.184811, 34.261792],
    常州市: [119.946973, 31.772752],
    苏州市: [120.619585, 31.299379],
    南通市: [120.864608, 32.016212],
    连云港市: [119.178821, 34.600018],
    淮安市: [119.021265, 33.597506],
    盐城市: [120.139998, 33.377631],
    扬州市: [119.421003, 32.393159],
    镇江市: [119.452753, 32.204402],
    泰州市: [119.915176, 32.484882],
    宿迁市: [118.275162, 33.963008],
  };

  function getOption(setting) {
    const { zoom, roam } = setting;
    var points = [
      { value: [118.8062, 31.9208], itemStyle: { color: "#4ab2e5" } },
      { value: [127.9688, 45.368], itemStyle: { color: "#4fb6d2" } },
      { value: [110.3467, 41.4899], itemStyle: { color: "#52b9c7" } },
      { value: [125.8154, 44.2584], itemStyle: { color: "#5abead" } },
      { value: [116.4551, 40.2539], itemStyle: { color: "#f34e2b" } },
      { value: [123.1238, 42.1216], itemStyle: { color: "#f56321" } },
      { value: [114.4995, 38.1006], itemStyle: { color: "#f56f1c" } },
      { value: [117.4219, 39.4189], itemStyle: { color: "#f58414" } },
      { value: [112.3352, 37.9413], itemStyle: { color: "#f58f0e" } },
      { value: [109.1162, 34.2004], itemStyle: { color: "#f5a305" } },
      { value: [103.5901, 36.3043], itemStyle: { color: "#e7ab0b" } },
      { value: [106.3586, 38.1775], itemStyle: { color: "#dfae10" } },
      { value: [101.4038, 36.8207], itemStyle: { color: "#d5b314" } },
      { value: [103.9526, 30.7617], itemStyle: { color: "#c1bb1f" } },
      { value: [108.384366, 30.439702], itemStyle: { color: "#b9be23" } },
      { value: [113.0823, 28.2568], itemStyle: { color: "#a6c62c" } },
      { value: [102.9199, 25.46639], itemStyle: { color: "#96cc34" } },
      { value: [119.4543, 25.9222] },
    ];
    const option = {
      backgroundColor: "",
      tooltip: {
        show: true,
      },
      geo: [
        {
          show: false,
          map: TempSources.compId,
        },
      ],
      series: [
        {
          type: "effectScatter",
          coordinateSystem: "geo",
          z: 5,
          data: [],
          symbolSize: 14,
          label: {
            normal: {
              show: true,
              formatter: function (params) {
                return (
                  "{fline|地点：" +
                  params.data.city +
                  "}\n{tline|" +
                  (params.data.info || "发生xx集件") +
                  "}"
                );
              },
              position: "top",
              backgroundColor: "rgba(254,174,33,.8)",
              padding: [0, 0],
              borderRadius: 3,
              lineHeight: 32,
              color: "#f7fafb",
              rich: {
                fline: {
                  padding: [0, 10, 10, 10],
                  color: "#ffffff",
                },
                tline: {
                  padding: [10, 10, 0, 10],
                  color: "#ffffff",
                },
              },
            },
            emphasis: {
              show: true,
            },
          },
          itemStyle: {
            color: "#feae21",
          },
        },
        {
          type: "effectScatter",
          coordinateSystem: "geo",
          z: 5,
          data: [],
          symbolSize: 14,
          label: {
            normal: {
              show: true,
              formatter: function (params) {
                return (
                  "{fline|地点：" +
                  params.data.city +
                  "}\n{tline|" +
                  (params.data.info || "发生xx集件") +
                  "}"
                );
              },
              position: "top",
              backgroundColor: "rgba(233,63,66,.9)",
              padding: [0, 0],
              borderRadius: 3,
              lineHeight: 32,
              color: "#ffffff",
              rich: {
                fline: {
                  padding: [0, 10, 10, 10],
                  color: "#ffffff",
                },
                tline: {
                  padding: [10, 10, 0, 10],
                  color: "#ffffff",
                },
              },
            },
            emphasis: {
              show: true,
            },
          },
          itemStyle: {
            color: "#e93f42",
          },
        },
        {
          type: "effectScatter",
          coordinateSystem: "geo",
          z: 5,
          data: [],
          symbolSize: 14,
          label: {
            normal: {
              show: true,
              formatter: function (params) {
                return (
                  "{fline|地点：" +
                  params.data.city +
                  "}\n{tline|" +
                  (params.data.info || "发生xx集件") +
                  "}"
                );
              },
              position: "top",
              backgroundColor: "rgba(8,186,236,.9)",
              padding: [0, 0],
              borderRadius: 3,
              lineHeight: 32,
              color: "rgba(255,255,255,1)",
              rich: {
                fline: {
                  padding: [0, 10, 10, 10],
                  color: "#ffffff",
                },
                tline: {
                  padding: [10, 10, 0, 10],
                  color: "#ffffff",
                },
              },
            },
            emphasis: {
              show: true,
            },
          },
          itemStyle: {
            color: "#08baec",
          },
        },
        //地图
        {
          tooltip: {
            show: true,
          },
          name: "名称",
          type: "map",
          mapType: TempSources.compId,
          roam: false,
          zoom: 1,
          label: {
            show: true,
            color: "rgba(255,255,255,1)",
            fontSize: 12,
            fontFamily: "Microsoft YaHei",
            emphasis: {
              color: "#000",
              fontSize: 16,
              fontFamily: "Courier New",
            },
          },
          itemStyle: {
            normal: {
              areaColor: "#003669",
              borderColor: "#3fdaff",
              borderWidth: 2,
              shadowColor: "rgba(63, 218, 255,0.6)",
              shadowBlur: 35,
            },
            emphasis: {
              areaColor: "#FA8C16",
              borderWidth: 0,
            },
          },
          data: [
            {
              name: "天河区",
              text1: "上传条数:20671条",
              text2: "销售码洋:73.8万元",
              text3: "库存码洋:1579.5万元",
            },
            {
              name: "海珠区",
              text1: "上传条数:500000条",
              text2: "销售码洋:155855万元",
              text3: "库存码洋:999999万元",
            },
          ],
        },
      ],
    };
    return option;
  }

  return {
    getOption,
  };
}
